package org.autoparser.exttree.terms;

import java.util.HashMap;
import java.util.Vector;

import org.htmlparser.Node;
import org.htmlparser.Tag;

public class ZAttributeTerm extends ZExtractTerm {
	
	private String attName;
	public ZAttributeTerm(final String columnName,final String attName){
		super.setColumnName(columnName.trim());
		this.attName = attName.trim();
	}
	@Override
	public void extractTerm(Node node, HashMap<String, Vector<String>> emap) {
		// TODO Auto-generated method stub
		if(node instanceof Tag){
			Tag tag = (Tag)node;
			String attValue = tag.getAttribute(attName);
			if(attValue == null)
				attValue="";
			Vector<String> set = emap.get(getColumnName());
			if(set == null){
				set = new Vector<String>();
				emap.put(getColumnName(), set);
			}
			set.add(attValue);
		}
	}
	public String getAttName() {
		return attName;
	}
	
}
